﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using blackhouse.JavaScript.JQuery;

namespace blackhouse.BlackApart.Web.Modules {
	public partial class InlineCurrencies : System.Web.UI.UserControl {


		#region Fields

		private DisplayCurrency currency = new DisplayCurrency();

		#endregion

		#region Methods

		private void ReceiveRequest() {
			if (this.IsPostBack && !string.IsNullOrEmpty(Request.Form["SetCurrency"]) && this.currency.ReceiveRequest(Request.Form["SetCurrency"]))
				Response.Redirect(Request.RawUrl, true);
		}

		protected override void OnInit(EventArgs e) {
			this.ReceiveRequest();

			base.OnInit(e);
		}

		protected override void OnLoad(EventArgs e) {
			base.OnLoad(e);

			this.AddJsFiles();

			this.currency = new DisplayCurrency();
			this.currency.Load();

			this.rptCurrencies.DataSource = this.currency.GetCurrencies();
			this.rptCurrencies.DataBind();

		}

		private void AddJsFiles() {
			JQueryLibraries jql = new JQueryLibraries();
			jql.IncludeFileBasedOnJQuery("blackhouse.BlackApart.Web.JavaScript.currency.js,blackhouse.BlackApart.Web");
		}

		#endregion


	}
}